<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/template.xhtml">
	<ui:define name="title">
		SGMF :: Parte do Carro
	</ui:define>

	<ui:define name="content">
		<p:fieldset legend="Parte do Carro">
			<h:form id="form">
				<h:inputHidden id="id" value="#{parteBean.parte.id}" rendered="#{parteBean.parte.id != null}" />
				<p:panelGrid columns="3" styleClass="borderless">
					<p:outputLabel value="Nome" for="nome" />
					<p:inputText id="nome" type="text" label="Nome" value="#{parteBean.parte.nome}" required="true"  maxlength="50" size="50" />
					<p:message for="nome" />
				</p:panelGrid>
				<br />
				<p:commandButton value="Novo" update="display" icon="ui-icon-new" />
				<p:commandButton id="salvar" value="Salvar"	action="#{parteBean.salvar}" update=":growl, :form, :datatable_form" icon="ui-icon-disk" />
			</h:form>
		</p:fieldset>
		<br />
		<h:form id="datatable_form">
			<p:dataTable id="datatable" var="parte"
				value="#{parteBean.partes}" rows="10" paginator="true"
				paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				currentPageReportTemplate="({currentPage} de {totalPages})" rowsPerPageTemplate="5,10,15" emptyMessage="Nenhum registro encontrado.">
				<f:facet name="header">
		        	Lista de Partes
		    	</f:facet>
				<p:column headerText="Nome">
					<h:outputText value="#{parte.nome}" />
				</p:column>
				<p:column headerText="Ações" styleClass="column-action">
					<p:commandButton icon="ui-icon-pencil" title="Editar" actionListener="#{parteBean.editar(parte)}" update=":growl, :form" />
					<p:commandButton icon="ui-icon-trash" title="Excluir" actionListener="#{parteBean.excluir(parte)}" update=":growl, datatable">
						<p:confirm header="Confirmação" message="Deseja realmente excluir esta parte do carro?" icon="ui-icon-alert" />
					</p:commandButton>
				</p:column>
			</p:dataTable>
		</h:form>
	</ui:define>
</ui:composition>

</html>